<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <title>添加课程</title>
</head>
<style>
    .layui-form{
        height: 250px;
       padding-top: 10px;
    }
    .buttonOne{
       width: 50%;
       height: 40px;
       margin-top: 30px;
       padding-left: 40%;
    }
    .buttonOne button{
        margin-left: 20px;
    }
    .layui-input, .layui-textarea{
        width: 70%;
    }
    .layui-form-label{
        padding: 9px 30px;
    }
    .layui-form-select .layui-edge{
      right: 30%;
    }
    .layui-form-select dl{
            min-width: 70%;
            left: 30px;
        }
      
</style>
<body>
   <form class="layui-form" action=" " id="form">
        <div class="layui-form-item">
                <label class="layui-form-label">课程中文名</label>
                <div class="layui-input-block">
                  <input type="text" name="course" required  lay-verify="required" placeholder="请输入课程中文名" autocomplete="off" class="layui-input course">
                </div>
              </div>
        <div class="layui-form-item">
          <label class="layui-form-label">课程英文名</label>
          <div class="layui-input-block">
            <input type="text" name="EnglishName" required  lay-verify="required" placeholder="请输入课程英文名" autocomplete="off" class="layui-input EnglishName">
          </div>
        </div>
        <div class="layui-form-item ">
          <label class="layui-form-label">学&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;期</label>
          <div class="layui-input-block term">
            <select name="term" lay-verify="required">
              <option value=""></option>
              <option value="大一上">大一上</option>
              <option value="大一下">大一下</option>
              <option value="大二上">大二上</option>
              <option value="大二下">大二下</option>
              <option value="大三上">大三上</option>
              <option value="大三下">大三下</option>
              <option value="大四上">大四上</option>
              <option value="大四下">大四下</option>
            </select>
          </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">课&nbsp;程&nbsp;描&nbsp;述</label>
            <div class="layui-input-block">
              <textarea name="courseRequire" placeholder="请输入内容" class="layui-textarea courseRequire"></textarea>
            </div>
          </div>
          <div class="layui-form-item">
              <div class="layui-input-block buttonOne">
                  <button class="layui-btn btn" lay-submit lay-filter="formDemo">立即提交</button>
                  <button type="reset" class="layui-btn layui-btn layui-btn-warm">重置</button>
                  
              </div>
          </div>
         
   </form>
</body>
<script>
    layui.use('form',function(){
      var form = layui.form;
    });
    $(function () {       
		$(".btn").click( function () {
			
		 /* 	var a= $("[name='course']").val();
	    	var b = $("[name='EnglishName']").val();
	    	var c = $("[name='courseRequire']").val();
	    	var d= $("[name='term']").val();
	    	alert(d); */
			
			var url="${pageContext.request.contextPath}/CouAdd";
			var param=$("#form").serialize();
			$.post(url,param,function(data){
			 	if(data.flag==0){
					alert(data.msg);
				}
				if(data.flag==1){
					window.parent.location.reload();//刷新父页面
			        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
			        parent.layer.close(index);
			        alert(data.msg);
				} 
			});
		});
    });
</script>
</html>